package com.scf.loanmanage.controller;

import com.scf.entity.Borrowers;
import com.scf.loanmanage.entity.AssetPreservation;
import com.scf.loanmanage.entity.PageBean;
import com.scf.loanmanage.service.ServiceImp.AssetPreservationImpl;
import com.scf.service.AppService;
import com.scf.uitl.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController

@RequestMapping("/AssetPreservation")
public class AssetPreservationController {

        @Resource
        AppService appService;

    @Resource
    AssetPreservationImpl assetPreservation;


    @GetMapping("/repaymentAll")
    public ResponseResult selectAll(Integer pageIndex, Integer pageSize) {
        List<AssetPreservation> repayments = assetPreservation.selectAll(pageIndex,pageSize);
        Integer selectcount = assetPreservation.selectcount();
        System.out.println("一共："+selectcount);
        ResponseResult resposeResult=new ResponseResult();
        resposeResult.setCode(200);
        PageBean<AssetPreservation> pageBean=new PageBean<>();
        pageBean.setBeanList(repayments);
        pageBean.setPageBegin(pageIndex);
        pageBean.setPageEnd(pageSize);
        pageBean.setTotalRecord(selectcount);
        resposeResult.setData(pageBean);
        return resposeResult;
    }

    @GetMapping("/selcetByname")
    public ResponseResult selectByname(String enterprisename,String code) {
        List<AssetPreservation> repayments = assetPreservation.selectByname(enterprisename, code);
        ResponseResult resposeResult=new ResponseResult();
        resposeResult.setCode(200);
        resposeResult.setData(repayments);
        return resposeResult;
    }

    @PostMapping("/sss")
    public ResponseResult s(@RequestBody Borrowers borrowers) {

        ResponseResult infoByBoid = appService.getInfoByBoid(borrowers);
                return infoByBoid;
    }
}
